<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vue 组件</title>
    <script src="./js/vue.min.js"></script>
</head>
<body>

    <div id="vm">
        {{ message }}
        <hr>
        <button-counter></button-counter>
    </div>

    <script>
        Vue.component('button-counter', {
            data: function () {
                return {
                    count: 0
                }
            },
            methods:{
                toCount(){
                    this.count += 1;
                }
            },
            template: '<button class="red" v-on:click="toCount">点击 {{ count }} 次.</button>',
        },)
        var vm = new Vue({
            el: '#vm',
            data: {
                message: 'Hello Vue!'
            }
        })
    </script>
    
</body>
</html>